var a = getApp();

Page({
    data: {
        page: 1,
        isLoadMore: !0,
        total_page: 0,
        listData: [],
        plugin_name: "拓客卡"
    },
    onLoad: function(a) {
        this.getData();
    },
    onReady: function() {},
    tokerSetMeal: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageH/toker/tokerSetMeal/tokerSetMeal?id=" + t
        });
    },
    gotoCode: function(a) {
        var t = a.currentTarget.dataset.id;
        wx.navigateTo({
            url: "/packageH/toker/tokerCode/tokerCode?id=" + t + "&name=" + this.data.plugin_name
        });
    },
    getData: function() {
        var t = this, e = a.getNetAddresss("plugin.customer-development.Frontend.controllers.card.index");
        a._postNetWork({
            url: e,
            success: function(e) {
                var o = e.data;
                if (1 != o.result) return a.tips(o.msg);
                t.data.total_page = o.data.last_page, t.data.total_page || (t.data.total_page = 0);
                var n = o.data.data;
                t.setData({
                    listData: n,
                    plugin_name: o.data.plugin_name
                }), wx.setNavigationBarTitle({
                    title: o.data.plugin_name ? o.data.plugin_name : "拓客卡"
                });
            }
        });
    },
    _getMoreData: function() {
        var t = this;
        if (this.data.isLoadMore = !1, !(this.data.page >= this.data.total_page)) {
            this.data.page += 1;
            var e = a.getNetAddresss("plugin.customer-development.Frontend.controllers.card.index");
            a._postNetWork({
                url: e,
                data: {
                    page: this.data.page
                },
                success: function(a) {
                    var e = a.data;
                    if (t.data.isLoadMore = !0, 1 === e.result) {
                        var o = e.data.data, n = t.data.listData.concat(o);
                        t.setData({
                            listData: n
                        });
                    } else t.data.page = t.data.page - 1, t.data.isLoadMore = !1;
                }
            });
        }
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function(a) {
        return console.log(a), {
            path: "/packageA/detail_v2/detail_v2?id=" + a.target.dataset.id
        };
    }
});